﻿using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Practices.EnterpriseLibrary.Validation;
using Barbar.MapReport.Common.Drawing.Commands;

namespace Barbar.MapReport.Common.Drawing {
  public abstract class RenderingServiceBase {
    public void Execute(DrawingCommand command) {
      if (command == null)
        throw new ArgumentNullException("command");
      Validator validator = ValidationFactory.CreateValidator(command.GetType());
      ValidationResults results = validator.Validate(command);
      if (!results.IsValid)
        throw new MapReportValidationException(results);
      ExecuteInternal(command);
    }

    protected abstract void ExecuteInternal(DrawingCommand command);
  }
}
